<template>
  <div class="purseForm">
    <view class="purse_text">
      请输入需要提现的金额
    </view> 

    <view class="forom">
      <uv-form ref="formsRef" :labelStyle="{fontSize:'24rpx'}" labelPosition="left" :model="model" :rules="rules" >
			<uv-form-item label="金额:" prop="name" borderBottom>
				<uv-input v-model="model.name"   border="none">
				</uv-input>
			</uv-form-item>
			<uv-form-item v-if="false" label="卡号：" prop="num" borderBottom >
				<uv-input v-model="model.num"    border="none">
				</uv-input>
			
			</uv-form-item>
			
		
		</uv-form>
    </view>

    <view class="button_formo">
      <uv-button type="error" text="提交" customStyle="margin-top: 10px" @click="submit"></uv-button>
    </view>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import {submit as submits}from '../https/api/purseDetail'

let formsRef = ref('')

let model = ref({
  name: '',
  cardNum: ''
})


let rules = ref( {
					'name': {
						type: 'string',
						required: true,
						message: '请填写金额',
						trigger: ['blur']
					},
					'num': {
						type: 'string',
						
						required: true,
						message: '请输入卡号',
						trigger: ['blur']
					},
				})

let submit = async() => {
let res = await  formsRef.value.validate()
 
  if(res){
    console.log(model.value.name)

    let res= await submits({
      amount:model.value.name
    })
    if(res.data){
  uni.navigateTo({
      url:'/pages/purseState'
    })
    uni.setStorageSync('TState',0)
    }else{
      uni.navigateTo({
      url:'/pages/purseState'
    })
    uni.setStorageSync('TState',1)
    }
  
  }
}
</script>

<style lang="scss" scoped>
.button_formo{
  margin-top: 40rpx;
  padding: 0 20rpx;
}
.forom{
  padding: 0 20rpx;
  background: white;
}
.purseForm{
  background: #F8F8F8;
  min-height: 100vh;
}
.purse_text{
  padding: 20rpx;
  font-family: Microsoft YaHei;
font-weight: 400;
font-size: 24rpx;
color: #000000;

}
</style>